#include "cputest.h"

// clock count base (20+1)
TEST(test301, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302a, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302b, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302c, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302d, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302e, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%ecx, %%mm4 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movd %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302f, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm1 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
// "paddb %%mm1, %%mm2" can be moved freely up
TEST(test302g, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"paddb %%mm1, %%mm2 \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
// "paddb %%mm1, %%mm0" can be moved freely up
TEST(test302h, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"paddb %%mm1, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302i, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"paddb %%mm0, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
TEST(test302j, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"paddb %%mm1, %%mm1 \n\t" \
	"pinsrw $0, %%ecx, %%mm0 \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"pextrw $0, %%mm0, %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )

// if you move mmx ops closer then clock count increases by 1 for every nop skipped
// actually, if you move "movl %%ecx, 8(%%esi)" down, then the first one increases by 2
// "movq %%mm0, 8(%%esi)" can be moved freely up
TEST(test304, \
	"l_%=: \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movl %%ecx, 8(%%esi) \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movq 8(%%esi), %%mm0 \n\t" \
	"nop \n\t" \
	"movq %%mm0, 8(%%esi) \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"movl 8(%%esi), %%eax \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"nop \n\t" \
	"loop l_%= \n\t" \
     )
test301: 21.269622
test302a: 31.418426
test302b: 31.454227
test302c: 31.464899
test302d: 31.414034
test302e: 32.478762
test302f: 32.477327
test302g: 32.459824
test302h: 32.460857
test302i: 32.455072
test302j: 32.454632
test304: 26.385207
